package resources
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.geom.ColorTransform;
	import flash.utils.Dictionary;
	
	import global.$R;
	
	import globals.$root;
	import loaders.GroupLoader;
	import loaders.LoadManager;

	public class RTProfile implements IResourceType
	{
		public static var NUM:int = 4; 
			
		public static var A:String = "flash/Profile1.swf";
		public static var B:String = "flash/Profile2.swf";
		
		public var id:String;
		
		public static var nameMap:Dictionary = new Dictionary;
		initNameMap();
		public static function initNameMap():void {
			nameMap[A] = "小红帽";
			nameMap[B] = "大灰狼";
		}
		
		public function RTProfile(id:String) {
			this.id = id;
		}
				
		public function load(loader:GroupLoader):void {
			loader.add(id, LoadManager.TYPE_DISPLAY_OBJECT);				
		}
		
		public function onLoad(loader:GroupLoader):void {
			var datas:Vector.<Bitmap> = new Vector.<Bitmap>(NUM);
			var mc:MovieClip = loader.items[id].loader.getContent() as MovieClip;
			for (var i:int = 0; i < NUM; i++) {
				datas[i] = mc.removeChildAt(0) as Bitmap;
			}
			$R.profile[id] = datas;
		}
		
		public static function layTo(bmp:DisplayObject, pos:int, max:int):void {			
			if (pos < max/2) {
				bmp.scaleX = 1;
//				bmp.x = -bmp.width/2;
			} else {
				bmp.scaleX = -1;
//				bmp.x = bmp.width/2;
			}
			bmp.x += (384 + pos*(1280-768)/max);
			bmp.y = -48;
		}
		
		public static function toFont(bmp:Bitmap):void {
			bmp.transform.colorTransform = null;
		}
		
		public static function  toBack(bmp:Bitmap):void {
			var cm:ColorTransform = new ColorTransform(0.4, 0.4, 0.4);
			bmp.transform.colorTransform = cm;
		}
	}
}